﻿<phone:PhoneApplicationPage 
    x:Class="BlobTowerDefense.GamePage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:custom="clr-namespace:BlobTowerDefense.Custom_Controls"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="PortraitOrLandscape"  Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="480"
    Name="Page_GamePage"
    shell:SystemTray.IsVisible="False" OrientationChanged="Page_GamePage_OrientationChanged" BackKeyPress="Page_GamePage_BackKeyPress" VerticalContentAlignment="Stretch" UseLayoutRounding="True">
    
    <UserControl.Resources>
        <Storyboard x:Name="animation_TowerStats_Show">
            <DoubleAnimation From="-200" To="0" Duration="0:0:1"
                             Storyboard.TargetName="translate_TowerStats"
                             Storyboard.TargetProperty="Y">
                <DoubleAnimation.EasingFunction>
                    <BackEase EasingMode="EaseOut" Amplitude="0.5"/>
                </DoubleAnimation.EasingFunction>
            </DoubleAnimation>
        </Storyboard>

        <Storyboard x:Name="animation_TowerStats_Hide">
            <DoubleAnimation From="0" To="-200" Duration="0:0:1"
                             Storyboard.TargetName="translate_TowerStats"
                             Storyboard.TargetProperty="Y">
                <DoubleAnimation.EasingFunction>
                    <BackEase EasingMode="EaseIn" Amplitude="0.5"/>
                </DoubleAnimation.EasingFunction>
            </DoubleAnimation>
        </Storyboard>

        <Storyboard x:Name="animation_NextWave_Show">
            <DoubleAnimation From="500" To="0" Duration="0:0:1"
                             Storyboard.TargetName="translate_NextWave"
                             Storyboard.TargetProperty="Y">
                <DoubleAnimation.EasingFunction>
                    <BackEase EasingMode="EaseOut" Amplitude="0.5"/>
                </DoubleAnimation.EasingFunction>
            </DoubleAnimation>
        </Storyboard>

        <Storyboard x:Name="animation_NextWave_Hide_BuildingMode">
            <DoubleAnimation From="0" To="700" Duration="0:0:1"
                             Storyboard.TargetName="translate_NextWave"
                             Storyboard.TargetProperty="Y">
                <DoubleAnimation.EasingFunction>
                    <BackEase EasingMode="EaseIn" Amplitude="0.5"/>
                </DoubleAnimation.EasingFunction>
            </DoubleAnimation>
        </Storyboard>

        <Storyboard x:Name="animation_NextWave_Hide_LaunchWave">
            <DoubleAnimation From="0" To="700" Duration="0:0:1"
                             Storyboard.TargetName="translate_NextWave"
                             Storyboard.TargetProperty="Y">
                <DoubleAnimation.EasingFunction>
                    <BackEase EasingMode="EaseIn" Amplitude="0.5"/>
                </DoubleAnimation.EasingFunction>
            </DoubleAnimation>
        </Storyboard>
        
        <Storyboard x:Name="animation_GameOver_Show">
            <DoubleAnimation From="400" To="0" Duration="0:0:1"
                             Storyboard.TargetName="translate_GameOver_Control"
                             Storyboard.TargetProperty="Y">
                <DoubleAnimation.EasingFunction>
                    <BackEase EasingMode="EaseOut" Amplitude="0.5"/>
                </DoubleAnimation.EasingFunction>
            </DoubleAnimation>
            <DoubleAnimation From="0" To="1" Duration="0:0:1"
                             Storyboard.TargetName="GameOver_Control"
                             Storyboard.TargetProperty="Opacity"/>
            <ObjectAnimationUsingKeyFrames Duration="0:0:0" 
                                           Storyboard.TargetName="GameOver_Control"
                                           Storyboard.TargetProperty="Visibility">
                <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Visible"/>
            </ObjectAnimationUsingKeyFrames>
        </Storyboard>
    </UserControl.Resources>

    <!-- LayoutRoot is the root grid where all page content is placed. -->
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="165"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="auto"/>
        </Grid.ColumnDefinitions>
        
        <Border x:Name="Canvas_TowerStats" Grid.RowSpan="2" VerticalAlignment="Top">
            <Border.Background>
                <LinearGradientBrush Opacity="0.5">
                    <GradientStop Color="#FF86C0E4"
                                      Offset="0"/>
                    <GradientStop Color="#FF86C0E4"
                                      Offset="0.5"/>
                    <GradientStop Color="#FFFFF500"
                                      Offset="1"/>
                </LinearGradientBrush>
            </Border.Background>
            <Border.RenderTransform>
                <TranslateTransform x:Name="translate_TowerStats"/>
            </Border.RenderTransform>            
            <Grid Name="Grid_TowerStats">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="240"/>
                    <ColumnDefinition Width="240"/>
                    <ColumnDefinition Width="0"/>
                </Grid.ColumnDefinitions>                
                <TextBlock Name="TextBlock_Damage"
                           Grid.Row="0"
                           Grid.Column="0"
                           Height="30"
                           Text="{Binding ConverterParameter=TowerStats_Label_Damage, Converter={StaticResource Localization}, Source={StaticResource Localization}}"/>
                <TextBlock Name="TextBlock_Range"
                           Grid.Row="1"
                           Grid.Column="0"
                           Height="30"
                           Text="{Binding ConverterParameter=TowerStats_Label_Range, Converter={StaticResource Localization}, Source={StaticResource Localization}}"/>
                <TextBlock Name="TextBlock_Speed"
                           Grid.Row="2"
                           Grid.Column="0"
                           Height="30"
                           Text="{Binding ConverterParameter=TowerStats_Label_Speed, Converter={StaticResource Localization}, Source={StaticResource Localization}}"/>            
                <TextBlock Name="TextBlock_Special"
                           Grid.Row="0"
                           Grid.Column="1"
                           Height="30"
                           Text="{Binding ConverterParameter=TowerStats_Label_Special, Converter={StaticResource Localization}, Source={StaticResource Localization}}"/>
                <TextBlock Name="TextBlock_Cost"
                           Grid.Row="1"
                           Grid.Column="1"
                           Height="30"
                           Text="{Binding ConverterParameter=TowerStats_Label_Cost, Converter={StaticResource Localization}, Source={StaticResource Localization}}"/>
                <TextBlock Name="TextBlock_UpgradeCost"
                           Grid.Row="2"
                           Grid.Column="1"
                           Height="30"
                           Text="{Binding ConverterParameter=TowerStats_Label_UpgradeCost, Converter={StaticResource Localization}, Source={StaticResource Localization}}"/>
                <TextBlock Name="TextBlock_GameState"
                           Grid.Row="3"
                           Grid.Column="0"
                           Grid.ColumnSpan="2"
                           Height="75"
                           Width="300"
                           HorizontalAlignment="Left"
                           FontSize="35"/>

                <Button Name="Button_TowerUpgrade"
                    Grid.Row="3"
                    Grid.Column="1"
                    Height="75"
                    Width="160"
                    HorizontalAlignment="Right"
                    BorderThickness="0"
                    Click="Button_TowerUpgrade_Click">
                    <Button.Background>
                        <ImageBrush ImageSource="../Images/OtherIcons/upgrade.png"/>
                    </Button.Background>
                </Button>
            </Grid>
        </Border>
        
        <Grid Name="Grid_PlayerStats"
              Margin="0,165,0,0"
              VerticalAlignment="Top"
              HorizontalAlignment="Left"
              Grid.Row="0"
              Grid.Column="0"
              Width="120"
              Grid.RowSpan="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="40"/>
                <RowDefinition Height="40"/>
                <RowDefinition Height="40"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto"/>
                <ColumnDefinition Width="auto"/>
            </Grid.ColumnDefinitions>
            <Image Name="Image_SpecialAttack"
               Grid.Row="0"
               Grid.Column="0"
               Source="../Images/OtherIcons/special_attack_off.png"
               Tap="UserControl_Tap"/>
            <Image Name="Image_Coins"
                   Grid.Row="1"
                   Grid.Column="0"
                   Source="../Images/OtherIcons/coin.png"
                   Tap="UserControl_Tap"/>
            <Image Name="Image_HP"
                   Grid.Row="2"
                   Grid.Column="0"
                   Source="../Images/OtherIcons/heart.png"
                   Tap="UserControl_Tap"/>
            
            <TextBlock Name="TextBlock_Coins"
                       Grid.Row="1"
                       Grid.Column="1"
                       HorizontalAlignment="Stretch"
                       VerticalAlignment="Center"
                       FontSize="30"
                       Foreground="Gold"
                       Tap="UserControl_Tap"/>
            <TextBlock Name="TextBlock_HP"
                       Grid.Row="2"
                       Grid.Column="1"
                       HorizontalAlignment="Stretch"
                       VerticalAlignment="Center"
                       FontSize="30"
                       Foreground="DarkRed"
                       Tap="UserControl_Tap"/>
        </Grid>

        <TextBlock Name="TextBlock_WaveNumber"
                   Grid.Row="2"                   
                   HorizontalAlignment="Center"
                   VerticalAlignment="Bottom"
                   Text="{Binding ConverterParameter=Wave_Label, Converter={StaticResource Localization}, Source={StaticResource Localization}}"/>
        <Button Name="Button_NextWave"
                Grid.Row="2"
                HorizontalAlignment="Center"
                VerticalAlignment="Bottom"
                Visibility="Collapsed"
                Content="{Binding ConverterParameter=NextWave_Label, Converter={StaticResource Localization}, Source={StaticResource Localization}}"
                Click="Button_NextWave_Click"/>
        
        
        <StackPanel Name="StackPanel_Towers"
                    Grid.Row="4" HorizontalAlignment="Stretch"
                    Orientation="Horizontal">
            <custom:ToggleButton_Custom x:Name="ToggleButton_Tower01"
                          Height="75"
                          Width="75"
                          BorderThickness="0"
                          BorderBrush="Yellow"
                          Margin="0"
                          Checked="ToggleButton_Tower_Checked"
                          Tap="UserControl_Tap">               
                <custom:ToggleButton_Custom.Background>
                    <ImageBrush ImageSource="..\Images\TowerIcons\TowerIcon_01.png"/>
                </custom:ToggleButton_Custom.Background>
            </custom:ToggleButton_Custom>
            <custom:ToggleButton_Custom x:Name="ToggleButton_Tower02"
                          Height="75"
                          Width="75"
                          BorderThickness="0"
                          BorderBrush="Yellow"
                          Margin="0"
                          Checked="ToggleButton_Tower_Checked"
                          Tap="UserControl_Tap">
                <custom:ToggleButton_Custom.Background>
                    <ImageBrush ImageSource="..\Images\TowerIcons\TowerIcon_02.png"/>
                </custom:ToggleButton_Custom.Background>
            </custom:ToggleButton_Custom>
            <custom:ToggleButton_Custom x:Name="ToggleButton_Tower03"
                          Height="75"
                          Width="75"
                          BorderThickness="0"
                          BorderBrush="Yellow"
                          Margin="0"
                          Checked="ToggleButton_Tower_Checked"
                          Tap="UserControl_Tap">
                <custom:ToggleButton_Custom.Background>
                    <ImageBrush ImageSource="..\Images\TowerIcons\TowerIcon_03.png"/>
                </custom:ToggleButton_Custom.Background>
            </custom:ToggleButton_Custom>
            <custom:ToggleButton_Custom x:Name="ToggleButton_Tower04"
                          Height="75"
                          Width="75"
                          BorderThickness="0"
                          BorderBrush="Yellow"
                          Margin="0"
                          Checked="ToggleButton_Tower_Checked"
                          Tap="UserControl_Tap">
                <custom:ToggleButton_Custom.Background>
                    <ImageBrush ImageSource="..\Images\TowerIcons\TowerIcon_04.png"/>
                </custom:ToggleButton_Custom.Background>
            </custom:ToggleButton_Custom>
            <custom:ToggleButton_Custom x:Name="ToggleButton_Tower05"
                          Height="75"
                          Width="75"
                          BorderThickness="0"
                          BorderBrush="Yellow"
                          Margin="0"
                          Checked="ToggleButton_Tower_Checked"
                          Tap="UserControl_Tap">
                <custom:ToggleButton_Custom.Background>
                    <ImageBrush ImageSource="..\Images\TowerIcons\TowerIcon_05.png"/>
                </custom:ToggleButton_Custom.Background>
            </custom:ToggleButton_Custom>
            <custom:ToggleButton_Custom x:Name="ToggleButton_Tower06"
                          Height="75"
                          Width="75"
                          BorderThickness="0"
                          BorderBrush="Yellow"
                          Margin="0"
                          Checked="ToggleButton_Tower_Checked"
                          Tap="UserControl_Tap">
                <custom:ToggleButton_Custom.Background>
                    <ImageBrush ImageSource="..\Images\TowerIcons\TowerIcon_06.png"/>
                </custom:ToggleButton_Custom.Background>
            </custom:ToggleButton_Custom>
        </StackPanel>

        <Border Name="Grid_NextWave"
                Grid.Row="2"
                HorizontalAlignment="Center"
                VerticalAlignment="Top"
                Tap="UserControl_Tap">
             
            <Border.Background>
                <LinearGradientBrush Opacity="0.5">
                    <GradientStop Color="#FF86C0E4"
                                      Offset="0"/>
                    <GradientStop Color="#FF86C0E4"
                                      Offset="0.5"/>
                    <GradientStop Color="#FFFFF500"
                                      Offset="1"/>
                </LinearGradientBrush>
            </Border.Background>
            <Border.RenderTransform>
                <TranslateTransform x:Name="translate_NextWave"/>
            </Border.RenderTransform>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="auto"/>                    
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition  Width="auto"/>
                <ColumnDefinition  Width="auto"/>
            </Grid.ColumnDefinitions>
            
            <TextBlock Grid.Row="0"
                       Grid.Column="0"
                       Grid.ColumnSpan="2"
                       HorizontalAlignment="Center"
                       Text="{Binding ConverterParameter=NextWave_Label, Converter={StaticResource Localization}, Source={StaticResource Localization}}"/>
            
            <StackPanel Name="NextWave_EnemyTypes"
                        Grid.Row="2"
                        Grid.Column="0"
                        Grid.ColumnSpan="2"
                        HorizontalAlignment="Center"
                        Orientation="Horizontal"/>
            <Button Name="NextWave_LaunchWave"
                    Grid.Row="3"
                    Grid.Column="0"
                    HorizontalAlignment="Center"
                    Content="{Binding ConverterParameter=LaunchWave_Label, Converter={StaticResource Localization}, Source={StaticResource Localization}}"
                    Click="NextWave_LaunchWave_Click"/>
            <Button Name="NextWave_BuildingMode"
                    Grid.Row="3"
                    Grid.Column="1"
                    HorizontalAlignment="Center"
                    Content="{Binding ConverterParameter=BuildingMode_Label, Converter={StaticResource Localization}, Source={StaticResource Localization}}"
                    Click="NextWave_BuildingMode_Click"/>
        </Grid>
        </Border>
        
        <Border Grid.Row="0"
                Grid.Column="0"
                Grid.RowSpan="4"
                Grid.ColumnSpan="2"
                HorizontalAlignment="Center"
                VerticalAlignment="Top"
                Name="GameOver_Control"
                Visibility="Collapsed">
            <Border.Background>
                <LinearGradientBrush Opacity="0.5">
                    <GradientStop Color="#FF86C0E4"
                                      Offset="0"/>
                    <GradientStop Color="#FF86C0E4"
                                      Offset="0.5"/>
                    <GradientStop Color="#FFFFF500"
                                      Offset="1"/>
                </LinearGradientBrush>
            </Border.Background>
            <Border.RenderTransform>
                <TranslateTransform x:Name="translate_GameOver_Control"/>
            </Border.RenderTransform>
            <StackPanel Orientation="Vertical">
                <TextBlock Text="{Binding ConverterParameter=GameOver_Label, Converter={StaticResource Localization}, Source={StaticResource Localization}}"/>
                <TextBox Name="TextBox_Nickname"/>
                <TextBlock Name="TextBlock_HighScore"/>
                <StackPanel Orientation="Horizontal">
                    <Button Name="Button_HighScore_Save" 
                            Content="{Binding ConverterParameter=SaveHighScore_Label, Converter={StaticResource Localization}, Source={StaticResource Localization}}"
                            Click="Button_HighScore_Save_Click"/>
                    <Button Name="Button_HighScore_DontSave" 
                            Content="{Binding ConverterParameter=DontSave_Label, Converter={StaticResource Localization}, Source={StaticResource Localization}}"
                            Click="Button_HighScore_DontSave_Click"/>
                </StackPanel>
            </StackPanel>
        </Border>
    </Grid>
</phone:PhoneApplicationPage>
